home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 352_01 / strppfnc.cpp < prev    next >
C/C++ Source or Header  |  1991-04-28  |  648b  |  29 lines

  1. // STRPPFNC.CPP  contains String::findchr()
  2. //        this routine searches a string for first occurance of a char
  3. //        obeys String::caseSens
  4. //        
  5. // NOTE: routine declared static in class {}. No 'this' ptr.        
  6. //
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <alloc.h>
  10. #include <iostream.h>
  11. #include <ctype.h>
  12.  
  13. #include "dblib.h"
  14.  
  15. int String::findchr ( char *a, int na, char c )
  16.     // search for first char c in string a. return offset.
  17.     {
  18.     if ( a != NULL )
  19.         {
  20.         _NORMALIZE ( a, char* );
  21.         for ( int i=0; i<na; ++i )
  22.             {
  23.             if ( 0==String::chrcmp (a[i], c) )    return i;
  24.             }
  25.         }
  26.     return -1;
  27.     };            // end String::findchr() 
  28.  
  29.